<?php
namespace App\Http\Controllers\Api\Ly;
use App\Common\Paginate;
use App\Common\Responses;
use Illuminate\Http\Request;
use App\Models\lak\Residential;
class HouseController
{

    public function detail(Request $request)
    {
        $id=$request->get('id');
        try {
            $data=Residential::detail($id);
            return Responses::success($data);
        }catch (\Exception $e)
        {
            return Responses::error([],0,$e->getMessage());
        }
    }

    public function show(Request $request){
        try {
            $params['page'] = (int)$request->get('page',1);
            $params['limit'] = (int)$request->get('limit',10);
            $params['location'] = (string)$request->get('location',"");
            $params['region'] = (string)$request->get('region',0);
            list($limit,$offset) = Paginate::paginate($params['page'],$params['limit']);
            $data = Residential::getSecharvr($params,$limit,$offset);
            $data['page'] =  (int)$params['page'];
            return Responses::success($data,20000);
        }catch (\Exception $exception){
            return Responses::error([],2001,$exception->getMessage());
        }
    }

}
